#pragma once
class CMenuMetrics;

interface IOwnerDrawMenu
{
	virtual HRESULT Initialize(HWND hwndParent) = 0;
	virtual void MeasureItem(__in MENUITEM *pmi, __inout MEASUREITEMSTRUCT *pmis) = 0;
	virtual void DrawItem(__in MENUITEM *pmi, __in DRAWITEMSTRUCT *pdis) = 0;
	virtual void SelectedItem(int id) = 0;
	virtual HRESULT SettingChange() = 0;
	virtual void Release() = 0;
};

class CClassicOwnerDrawMenu : public IOwnerDrawMenu
{
public:
	CClassicOwnerDrawMenu() :
		_idLastSelected(-1)
	{
	}

	// IOwnerDrawMenu
	__override HRESULT Initialize(HWND hwndParent);
	__override void MeasureItem(__in MENUITEM *pmi, __inout MEASUREITEMSTRUCT *pmis);
	__override void DrawItem(__in MENUITEM *pmi, __in DRAWITEMSTRUCT *pdis);
	__override void SelectedItem(int id);
	__override HRESULT SettingChange();
	__override void Release();

private:
	void _DrawMenuItem(__in MENUITEM *pmi, __in DRAWITEMSTRUCT *pdis);
	void _InitMenuDC(__in MENUITEM *pmi, __in DRAWITEMSTRUCT *pdis);

	HWND _hwndParent;
	int _idLastSelected;

	// Menu metrics
	static const int _cxMenuMargin = 0;
	static const int _cyMenuMargin = 0;
	static const int _cxGutter = 5;
	static const int _cxGutterMargin = 2;
	static const int _cxGutterLine = 1;
	static const int _cxCheckmark = 16;
	static const int _cyCheckmark = 16;
	static const int _cySeparator = 1;
	static const DWORD _rgbPreviousSelection = RGB(251,245,55);
};




class CVistaOwnerDrawMenu : public IOwnerDrawMenu
{
public:
	CVistaOwnerDrawMenu();
	~CVistaOwnerDrawMenu();

	// IOwnerDrawMenu
	__override HRESULT Initialize(HWND hwndParent);
	__override void MeasureItem(__in MENUITEM *pmi, __inout 
		MEASUREITEMSTRUCT *pmis);
	__override void DrawItem(__in MENUITEM *pmi, __in DRAWITEMSTRUCT 
		*pdis);
	__override void SelectedItem(int id);
	__override HRESULT SettingChange();
	__override void Release();

private:
	void _DrawMenuItem(__in MENUITEM *pmi, __in DRAWITEMSTRUCT *pdis);

	HWND _hwndParent;
	CMenuMetrics *_pMetrics;
	int _idLastSelected;

	static const DWORD _rgbPreviousSelection = RGB(251,245,55);
};

